package com.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bean.PedidoBean;

public class Pedidos extends AbstractAction {

	private static final String INIT_URL					= "/programs/pedidos/init.jsp";
	private static final String LIST_URL					= "/programs/pedidos/list.jsp";
	private static final String RESPONSE_URL 				= "/programs/pedidos/response.jsp?response=";
	private static final String PRODUCT_URL					= "/programs/pedidos/products.jsp?product=";
	
	
	private static final String INIT_ACTION 				= "init";
	private static final String LIST_ACTION 				= "list";
	private static final String ADD_ACTION 					= "add";
	private static final String REMOVE_ACTION 				= "remove";
	private static final String MODIFY_ACTION 				= "modify";
	private static final String PRODUCT_ACTION 				= "product";
	
	@Override
	public String doAction(HttpServletRequest req, HttpServletResponse res) {
		// TODO Auto-generated method stub
		String action=req.getParameter("action");
		PedidoBean bean=new PedidoBean();
		req.getSession().setAttribute("bean",bean);
		if(INIT_ACTION.equals(action)){
			return INIT_URL;
		}
		if(LIST_ACTION.equals(action)){
			return LIST_URL;
		}
		if(ADD_ACTION.equals(action)){
			bean.add(req);
		}
		if(PRODUCT_ACTION.equals(action)){
			String product=null;
			if(req.getParameter("product")!=null){
				product=req.getParameter("product").toString();
			}
			return PRODUCT_URL+product;
		}
		/*if(REMOVE_ACTION.equals(action)){
			bean.remove(req);
		}
		if(MODIFY_ACTION.equals(action)){
			bean.modify(req);
		}*/
		return RESPONSE_URL;
	}

}
